﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Utils.Extention;
using Utils.Common;
#region Version Info
/* ========================================================================
* 【本页面功能概述】
*
* 作者：wangjianfeng 创建时间：2012/7/31 21:02:59
* 文件名：AdminPass.cs
*
* 修改者： 时间：
* 修改说明：
* ========================================================================
*/
#endregion
namespace ChinaLeg.Web.WebAdmin.Admin
{
    public partial class AdminPass : ChinaLeg.Web.Lib.PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtOldPass.Text))
            {
                Response.Write(JScript.Alert("原密码不能为空！"));
                return;
            }
            if (string.IsNullOrEmpty(txtNewPass.Text))
            {
                Response.Write(JScript.Alert("新密码不能为空！"));
                return;
            }
            if (string.IsNullOrEmpty(txtNewPass1.Text))
            {
                Response.Write(JScript.Alert("确认新密码不能为空！"));
                return;
            }
            if (txtNewPass.Text != txtNewPass1.Text)
            {
                Response.Write(JScript.Alert("两次输入的新密码不一致！"));
                return;
            }

            string UserName = this.GetUserName();
            ChinaLeg.Model.Manager model = ChinaLeg.BLL.Manager.Instance.GetModel(UserName);

            string oldPass = txtOldPass.Text.Trim();
            if (oldPass.MD5Encrypt() != model.PassWord)
            {

                Response.Write(JScript.Alert("原密码输入错误！"));
                return;

            }

            model.PassWord = txtNewPass.Text.MD5Encrypt();

            ChinaLeg.BLL.Manager.Instance.Update(model);

            Response.Write(JScript.Alert("密码修改成功！"));

        }
    }
}